﻿using System;
using System.Collections.Generic;

namespace SWF.Runtime
{
    public struct PlaceOperation
    {
        public uint Character;

        public string Name;
        public uint Depth;
        public uint ClipDepth;
        public uint Ratio;
        public ColorTransform Color;
        public Matrix PlaceMatrix;

        public List<ActionOperation> ClipActions;

        public static PlaceOperation CreateFromTag(dynamic tag)
        {
            if (!(tag is IPlaceObject)) return new PlaceOperation() { ClipActions = new List<ActionOperation>() };

            return new PlaceOperation()
                {
                    Character = tag.HasCharacter ? tag.Character : (uint)0,
                    Name = tag.HasName ? tag.Name : "",

                    Depth = tag.Depth,
                    PlaceMatrix = tag.HasMatrix ? tag.Matrix : Matrix.Identity,
                    Color = tag.HasColorTransform ? tag.ColorTransform : new ColorTransform(),

                    ClipDepth = tag.HasClipDepth ? tag.ClipDepth : (uint)0,
                    Ratio = tag.HasRatio ? tag.Ratio : (uint)0,

                    ClipActions = new List<ActionOperation>(),
                };
        }
    }
    public struct RemoveOperation
    {
        public uint Character;
        public uint Depth;

        public static RemoveOperation CreateFromTag(dynamic tag)
        {
            return new RemoveOperation()
                {
                    Character = (uint)(tag is RemoveObjectTag ? tag.Character : 0),
                    Depth = (uint)(tag.Depth),
                };
        }
    }
    public struct ActionOperation
    {
        public ActionKind Action;
    }
}
